﻿using Autofac;
using Autofac.Extensions.DependencyInjection;
using SqlSugar;
using SqlSugarWebApi.DataContext.Services;


namespace SqlSugarWebApi.DataContext.AutoFac
{
    public static class IAutofacHostBuilderExtensions
    {
        public static IHostBuilder UseAutofac(this IHostBuilder hostBuilder)
        {
            return hostBuilder.UseServiceProviderFactory(new AutofacServiceProviderFactory())
                .ConfigureContainer<ContainerBuilder>(containerBuilder =>
                {
                    #region 注册
                    containerBuilder.RegisterType<UserService>().As<IUserService>().InstancePerLifetimeScope();
                    #endregion
                });
        }
    }
}
